﻿<div ng-controller="merchantController">
	<div class="wrapper border-bottom white-bg page-heading">
		<div class="col-lg-pull-12">
			<ol class="breadcrumb">
				<li><a href="javascript:void(0)" ng-click="goBack()">商户</a></li>
				<li class="active" ng-bind="breadcrumb"></li>
			</ol>
		</div>
	</div>
    <form name="_form" class="form-horizontal w5c-form" w5c-form-validate="model.validateOptions" role="form" novalidate>
        <div class="form-group form-group-sm">
            <label class="col-sm-2 control-label">名称</label>
            <div class="col-sm-3">
                <input type="text" name="name" class="form-control " ng-model="model.name" required>
            </div>
        </div>
        <div class="form-group form-group-sm">
            <label class="col-sm-2 control-label">账户</label>
            <div class="col-sm-3">
                <input type="text" name="mobile" class="form-control " ng-model="model.mobile" required>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0">
            <label class="col-sm-2 control-label">商户号</label>
            <div class="col-sm-3">
                <input type="text" name="merchant_no" class="form-control " ng-model="model.merchant_no">
            </div>
        </div>
        <!--<div class="form-group form-group-sm">
        <label class="col-sm-2 control-label">上级商户</label>
        <div class="col-sm-3">
            <input type="text" name="parent_no" class="form-control " ng-model="model.parent_no">
        </div>
    </div>-->
        <div class="form-group form-group-sm" ng-if="model.id==0">
            <label class="col-sm-2 control-label">密码</label>
            <div class="col-sm-3">
                <input type="password" name="password" class="form-control " ng-model="model.password" required>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id==0">
            <label class="col-sm-2 control-label">确认密码</label>
            <div class="col-sm-3">
                <input type="password" name="re_password" class="form-control " ng-model="model.re_password" required>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id==0">
            <label class="col-sm-2 control-label">账号权限:</label>
            <div class="col-sm-3">
                <select name="role_id" class="form-control input-sm" ng-model="model.roleid" ng-options="item.id as item.name for item in rolelist"></select>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="action=='oem'">
            <label class="col-sm-2 control-label">是否OEM商户</label>
            <div class="col-sm-2">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="is_oem" ng-model="model.is_oem" ng-disabled="model.id>0"> {{model.is_oem?'是':'否'}}
                    </label>
                </div>
            </div>
            <label class="col-sm-2 control-label">是否APP支付代付</label>
            <div class="col-sm-2">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="trade_outpay" ng-model="model.trade_outpay"> {{model.trade_outpay?'是':'否'}}
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="action=='platform'">
            <label class="col-sm-2 control-label">平台商户</label>
            <div class="col-sm-3">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="is_platform" ng-model="model.is_platform" ng-disabled="model.id>0"> {{model.is_platform?'是':'否'}}
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0&&model.is_oem">
            <label class="col-sm-2 control-label">hf快捷商户</label>
            <div class="col-sm-2">
                <input type="text" name="hf_set.quick_mchid" class="form-control " ng-model="model.setting.hf_set.quick_mchid">
            </div>
            <label class="col-sm-2 control-label">hf扫码商户</label>
            <div class="col-sm-2">
                <input type="text" name="hf_set.native_mchid" class="form-control " ng-model="model.setting.hf_set.native_mchid">
            </div>
            <label class="col-sm-2 control-label">hf扫码KEY</label>
            <div class="col-sm-2">
                <input type="text" name="hf_set.native_key" class="form-control " ng-model="model.setting.hf_set.native_key">
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0&&model.is_oem">
            <label class="col-sm-2 control-label">微信APPID</label>
            <div class="col-sm-2">
                <input type="text" name="wx_app.app_id" class="form-control " ng-model="model.setting.wx_app.app_id">
            </div>
            <label class="col-sm-2 control-label">微信APPSecret</label>
            <div class="col-sm-2">
                <input type="text" name="wx_app.app_secret" class="form-control " ng-model="model.setting.wx_app.app_secret">
            </div>
            <label class="col-sm-2 control-label">微信app商户</label>
            <div class="col-sm-2">
                <input type="text" name="wx_app.mchid" class="form-control " ng-model="model.setting.wx_app.mchid">
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0&&model.is_oem">
            <label class="col-sm-2 control-label">公钥</label>
            <div class="col-sm-10">
                <textarea name="model.public_key" class="form-control" ng-model="model.public_key"></textarea>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0&&model.is_oem">
            <label class="col-sm-2 control-label">oss key</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.key" class="form-control " ng-model="model.setting.oss_set.key">
            </div>
            <label class="col-sm-2 control-label">oss secret</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.secret" class="form-control " ng-model="model.setting.oss_set.secret">
            </div>
            <label class="col-sm-2 control-label">app key</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.app_key" class="form-control " ng-model="model.setting.oss_set.app_key">
            </div>
            <label class="col-sm-2 control-label">app secret</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.app_secret" class="form-control " ng-model="model.setting.oss_set.app_secret">
            </div>
            <label class="col-sm-2 control-label">指定角色Arn</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.arn" class="form-control " ng-model="model.setting.oss_set.arn">
            </div>
            <label class="col-sm-2 control-label">oss库名</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.bucket_name" class="form-control " ng-model="model.setting.oss_set.bucket_name">
            </div>
            <label class="col-sm-2 control-label">库区域</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.endpoint" class="form-control " ng-model="model.setting.oss_set.endpoint">
            </div>
            <label class="col-sm-2 control-label">oss url</label>
            <div class="col-sm-2">
                <input type="text" name="oss_set.img_url" class="form-control " ng-model="model.setting.oss_set.img_url">
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="action!='merchant'">
            <label class="col-sm-2 control-label">是否供应商</label>
            <div class="col-sm-1">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="is_supplier" ng-model="model.is_supplier"> {{model.is_supplier?'是':'否'}}
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group form-group-sm">
            <label class="col-sm-2 control-label">状态</label>
            <div class="col-sm-10">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="disabled" ng-model="model.disabled"> {{model.disabled?'禁用':'启用'}}
                    </label>
                </div>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id!=0">
            <label class="col-sm-2 control-label">用户类型:</label>
            <div class="col-sm-3">
                <select name="role_id" class="form-control input-sm" ng-model="model.usertype">
                    <option value="">选择用户类型</option>
                    <option value="1">管理员</option>
                    <option value="2">oem</option>
                    <option value="3">普通用户</option>
                    <option value="4">分销商</option>
                    <option value="5">供应商</option>
                </select>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id!=0">
            <label class="col-sm-2 control-label">账号权限:</label>
            <div class="col-sm-3">
                <select name="role_id" class="form-control input-sm" ng-model="model.roleid" ng-options="item.id as item.name for item in rolelist"></select>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.roleid == '4'">
            <label class="col-sm-2 control-label">分销商比例:</label>
            <div class="col-sm-3">
                <input type="number" name="poundage" class="form-control " ng-model="model.poundage" pattern="^(100|[1-9]?\d(\.\d)?)$">
            </div>
            <div class="col-sm-1 row"><p class="form-control-static">%</p></div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0">
            <label class="col-sm-2 control-label">备注</label>
            <div class="col-sm-6">
                <textarea name="remark" class="form-control" ng-model="model.remark">{{model.remark}}</textarea>
            </div>
        </div>
        <div class="form-group form-group-sm" ng-if="model.id>0">
            <div class="col-sm-2">
                <button type="button" class="btn btn-primary btn-sm" ng-click="open_payment()">
                    <i class="fa fa-plus"></i> 增加支付方式
                </button>
            </div>
        </div>
        <table class="table table-hover" ng-if="model.id>0">
            <thead>
                <tr>
                    <th width="100">通道</th>
                    <th width="100">名称</th>
                    <th width="80">是否启用</th>
                    <th width="100">编号</th>
                    <th width="80">支付费率</th>
                    <th width="80">结算类型</th>
                    <th width="80">结算费</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="item in model.payments">
                    <td>{{item.payment.channel|channel_name}}({{item.payment.channel}})</td>
                    <td>{{item.payment.name}}</td>
                    <td>{{item.payment.is_open?'启用':'禁用'}}</td>
                    <td colspan="7">
                        <table class="table">
                            <tr ng-repeat="settle in item.settles">
                                <td>{{settle.code}}</td>
                                <td><input name="settle.fee" type="number" class="form-control input-sm" ng-model="settle.fee" w5c-dynamic-element required></td>
                                <td><input name="settle.settle_type" type="text" class="form-control input-sm" ng-model="settle.settle_type"></td>
                                <td><input name="settle.settle" type="number" class="form-control input-sm" ng-model="settle.settle" w5c-dynamic-element required></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="form-group form-group-sm">
            <label class="col-sm-2 control-label"></label>
            <div class="col-sm-3">
                <button type="submit" w5c-form-submit="save()" class="btn btn-primary btn-sm" btn-loading="psdisabled.save" loading-text="保存中..." ng-disabled="psdisabled.save">
                    <i class="fa fa-save"></i> 保存
                </button>
                <button ng-click="goBack()" class="btn btn-primary btn-sm"><i class="fa fa-rotate-left"></i> 取消</button>
            </div>
        </div>
    </form>
</div>